package com.yellow.userservice.controller;
import com.yellow.userservice.entity.User;
import com.yellow.userservice.service.UserServiceImpl;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j;
import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.web.bind.annotation.*;

/**
 * @author: hy
 * @create: 2024-01-16
 */

@Slf4j
@RestController
@Tag(name="用户",description = "用户操作")
@CrossOrigin(origins = "*",maxAge =3600 )
@RequestMapping("/user")
public class UserController {
    @Resource
    private UserServiceImpl userService;

    @LoadBalanced
    @GetMapping("/{name}")
    @Operation(summary = "查询", description = "按照用户名查询用户")
    public User selectUserByName(@PathVariable("name") @Parameter(description = "用户名") String name) throws InterruptedException {
        return userService.selectByName(name);
    }

    @GetMapping("/getAvatar/{name}")
    @Operation(summary = "查询",description = "根据用户名查询用户头像地址")
    public String getAvatarByName(@PathVariable("name") String name){
        return userService.selectAvatarUrl(name);
    }


}
